"use client";
import { Card, List } from "antd";
import TagList from "../TagList";
import Link from "next/link";
import "./index.css";

interface Props {
  questionBankId: number;
  questionList: API.QuestionVO[];
  cardTitle?: string;
}
/**
 * 题目列表组件
 * @param 题目列表组件
 * @returns
 */
const QuestionList: React.FC<Props> = ({
  questionList,
  cardTitle,
  questionBankId,
}) => {
  return (
    <Card className="questionList" title={cardTitle}>
      <List
        itemLayout="horizontal"
        dataSource={questionList}
        renderItem={(item) => (
          <List.Item extra={<TagList tagList={item.tagList || []} />}>
            <List.Item.Meta
              title={
                <Link
                  href={
                    questionBankId
                      ? `/bank/${questionBankId}/question/${item.id}`
                      : `/question/${item.id}`
                  }
                >
                  {item.title}
                </Link>
              }
              description={item.content}
            />
          </List.Item>
        )}
      />
    </Card>
  );
};
export default QuestionList;
